import java.io.IOException;
import java.sql.SQLException;

public class Login {
    public String username = "bit";
    public String passWord = "123";

    public void loginInfo(String username,String passWord) throws UserNameException,PassWordException{
        if(!this.username.equals(username)) {
            //System.out.println("用户名有问题...");
            throw new UserNameException("用户名有问题，你输入的用户名是： "+username);
            //return;
        }

        if(!this.passWord.equals(passWord)) {
           /* System.out.println("密码有问题...");
            return;*/
            throw new PassWordException("密码有问题, 你输入的密码是："+passWord);
        }

        System.out.println("登录成功！");
    }

    public static void main1(String[] args) {
        Login login = new Login();
        try {
            login.loginInfo("bit","1253");
        }catch (UserNameException e) {
            e.printStackTrace();
            System.out.println("捕获了 UserNameException 异常");
        }catch (PassWordException e) {
            e.printStackTrace();
            System.out.println("捕获了 PassWordException 异常");
        }
    }

    public static void func2() {
        try {
            int[] array = null;
            System.out.println(array.length);
        }catch (NullPointerException e) {
            try {
                int[] array = {1, 2, 3};
                System.out.println(array[9]);
            }catch (ArrayIndexOutOfBoundsException e2) {

            }
        }finally {
            System.out.println("hahaha");
        }
    }

    public static void main(String[] args) {
        func2();

        try {

        }finally {

        }
    }
}
